public class Solution {
    public boolean isPalindrome(int x) {
        String xString = String.valueOf(x);
        int head = 0;
        int tail = xString.length() - 1;
        while(head < tail) {
            if (xString.charAt(head) != xString.charAt(tail)) {
                return false;
            }
            head++;
            tail--;
        }
        return true;
    }

    public boolean isPalindrome2(int x) {
        if (x < 0) {
            return false;
        }

        long rx = 0;
        int tmp = x;
        while (tmp != 0) {
            rx = rx * 10 + tmp % 10;
            tmp /= 10; 
        }
        return rx == x;
    }
}
